package com.itbaima.thymeleaf;

import com.itbaima.entity.User;
import com.itbaima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class ThymeleafController {

    @Autowired
    private UserService userService;

    @RequestMapping("/thymeleaf/users")
    public String users(Model model) {
        List<User> users = userService.findAll();
        model.addAttribute("users", users);
        model.addAttribute("msg", "hello, thymeleaf");
        // thymeleaf默认在resources\templates下存放模板页面
        return "table-standard";
    }
}
